package com.wagn.vod.controller;

import com.wagn.utils.R;
import com.wagn.vod.service.VodService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;


@CrossOrigin
@RestController
@RequestMapping("/service_vod/upload")
public class VodController {

    @Autowired
    private VodService vodService;

    @PostMapping("uploadlocal")
    public R uploadlocal(MultipartFile file){
        String idAndName = vodService.uploadlocal(file);
        return R.ok()
                .data("id",idAndName.substring(0,idAndName.lastIndexOf(',')))
                .data("name",idAndName.substring(idAndName.lastIndexOf(',')+1,idAndName.length()));
    }

    //通过id删除云视频
    @DeleteMapping("remove/{id}")
    public R remove(@PathVariable String id){
        Boolean rs = vodService.remove(id);
        return R.ok().data("do",rs);
    }
}
